package com.gitee.itembucket.util.germ

import com.germ.germplugin.api.dynamic.gui.GermGuiItem
import com.gitee.itembucket.util.germ.germ.GermPartDSL
import org.bukkit.inventory.ItemStack
import taboolib.library.configuration.ConfigurationSection

class GermItemDSL : GermPartDSL<GermGuiItem>() {

    var width = ""
    var height = ""
    var size = "1"
    var item: ItemStack? = null

    override val type: String = "texture"

    override fun infuse(config: ConfigurationSection) {
        name = config.name
        config.getString("locationX")?.let { locationX = it }
        config.getString("locationY")?.let { locationY = it }
        config.getString("locationZ")?.let { locationZ = it }
        config.getString("size")?.let { size = it }
        config.getString("width")?.let { width = it }
        config.getString("height")?.let { height = it }
        config.getString("width")?.let { width = it }

        enable = config.getBoolean("enable")
    }

    override fun create(): GermGuiItem {
        return GermGuiItem(name).also {
            it.locationX = locationX
            it.locationY = locationY
            it.locationZ = locationZ
            it.enable = enable
            it.width = width
            it.height = height
            it.size = size
            item?.apply { it.itemStack = this }
        }
    }
}